<template>
	<view class="room_bar">
		<chatSuitMain ref="chatSuitMain" :username="username" :chatType="chatType" @inputFocused="closeAllModal"
		@openRecordModal="toggleRecordModal" @openFunModal="openFunModal"></chatSuitMain>
		<chatSuitImage ref="chatSuitImage" :username="username" :chatType="chatType"></chatSuitImage>

		<swiper :class="showFunModal" :indicator-dots="true" :autoplay="false" :interval="5000" :duration="1000">
			<swiper-item>
				<view :class="'other_func ' + (isIPX ? 'other_func_X' : '')">
					<view class="open_camera" @tap="openCamera">
						<image src="https://rsyl.oss-cn-beijing.aliyuncs.com/3a3045e9e91c48a08ed9c2084907c078.png"></image>
						相机
					</view>
					<view class="send_image" @tap="sendImage">
						<image src="https://rsyl.oss-cn-beijing.aliyuncs.com/20ecd0cc209c42a68a37335bd9bd07f8.png"></image>
						相册
					</view>
				</view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	let msgType = require("../msgtype");
	import chatSuitImage from "./suit/image/image";
	import chatSuitMain from "./suit/main/main";

	let FUNMODAL_STATUS = {
		OPENED: "showFunModal",
		CLOSED: "fun_list",
	};

	export default {
		data() {
			return {
				__comps__: {
					main: null,
					emoji: null,
					image: null,
					location: null,
					video: null,
				},
				isIPX: "",
				showFunModal: FUNMODAL_STATUS.CLOSED,
			};
		},

		components: {
			chatSuitImage,
			chatSuitMain,
		},
		props: {
			username: {
				type: Object,
				default: () => ({}),
			},
			chatType: {
				type: String,
				default: msgType.chatType.SINGLE_CHAT,
			},
		},

		// lifetimes
		created() {},

		beforeMount() {},

		moved() {},

		destroyed() {},

		onLoad() {
			this.isIPX = false //getApp().globalData.isIPX
		},

		methods: {
			// 事件有长度限制：仅限 26 字符
			toggleRecordModal() {
				this.$emit("tapSendAudio", null, {
					bubbles: true,
					composed: true,
				});
			},
			openCamera() {
				this.$refs.chatSuitImage.openCamera();
			},

			sendImage() {
				this.$refs.chatSuitImage.sendImage();
			},

			callVideo() {
				this.$refs.chatSuitPtopcall.show();
			},
			openFunModal() {
				this.showFunModal = FUNMODAL_STATUS.OPENED
			},
			closeFunModal() {
				this.showFunModal = FUNMODAL_STATUS.CLOSED
			},
			closeAllModal() {
				this.closeFunModal()
			},
		},
	};
</script>
<style>
	@import "./inputbar.css";
</style>
